home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog 119
/
FreelogNo119-MarsAvril2014.iso
/
Securite
/
Malwarebytes Anti-Malware
/
mbam-setup-1.75.0.1300.exe
/
{app}
/
Chameleon
/
chameleon.chm
/
js
/
jquery.main.js
< prev
Wrap
Text File
|
2012-03-03
|
6KB
|
199 lines
$(function(){
clearInputs();
initNav();
initPlugins();
});
function initNav(){
var duration = 500;
$('#nav > li').each(function(){
var holder = $(this);
var drop = $('div.drop',holder);
var list = $('>ul',drop);
holder.mouseenter(function(){
if (drop.is(':hidden')) {
drop.show();
list.css({marginTop:-list.outerHeight()}).animate({marginTop:0},duration);
} else {
list.stop().animate({marginTop:0},duration);
}
}).mouseleave(function(){
list.stop().animate({marginTop:-list.outerHeight()},duration,function(){
drop.hide();
});
});
});
}
function clearInputs()
{
clearFormFields({
clearInputs: true,
clearTextareas: true,
passwordFieldText: true,
addClassFocus: "focus",
filterClass: "default"
});
}
function clearFormFields(o)
{
if (o.clearInputs == null) o.clearInputs = true;
if (o.clearTextareas == null) o.clearTextareas = true;
if (o.passwordFieldText == null) o.passwordFieldText = false;
if (o.addClassFocus == null) o.addClassFocus = false;
if (!o.filterClass) o.filterClass = "default";
if(o.clearInputs) {
var inputs = document.getElementsByTagName("input");
for (var i = 0; i < inputs.length; i++ ) {
if((inputs[i].type == "text" || inputs[i].type == "password") && inputs[i].className.indexOf(o.filterClass) == -1) {
inputs[i].valueHtml = inputs[i].value;
inputs[i].onfocus = function () {
if(this.valueHtml == this.value) this.value = "";
if(this.fake) {
inputsSwap(this, this.previousSibling);
this.previousSibling.focus();
}
if(o.addClassFocus && !this.fake) {
this.className += " " + o.addClassFocus;
this.parentNode.className += " parent-" + o.addClassFocus;
}
}
inputs[i].onblur = function () {
if(this.value == "") {
this.value = this.valueHtml;
if(o.passwordFieldText && this.type == "password") inputsSwap(this, this.nextSibling);
}
if(o.addClassFocus) {
this.className = this.className.replace(o.addClassFocus, "");
this.parentNode.className = this.parentNode.className.replace("parent-"+o.addClassFocus, "");
}
}
if(o.passwordFieldText && inputs[i].type == "password") {
var fakeInput = document.createElement("input");
fakeInput.type = "text";
fakeInput.value = inputs[i].value;
fakeInput.className = inputs[i].className;
fakeInput.fake = true;
inputs[i].parentNode.insertBefore(fakeInput, inputs[i].nextSibling);
inputsSwap(inputs[i], null);
}
}
}
}
if(o.clearTextareas) {
var textareas = document.getElementsByTagName("textarea");
for(var i=0; i<textareas.length; i++) {
if(textareas[i].className.indexOf(o.filterClass) == -1) {
textareas[i].valueHtml = textareas[i].value;
textareas[i].onfocus = function() {
if(this.value == this.valueHtml) this.value = "";
if(o.addClassFocus) {
this.className += " " + o.addClassFocus;
this.parentNode.className += " parent-" + o.addClassFocus;
}
}
textareas[i].onblur = function() {
if(this.value == "") this.value = this.valueHtml;
if(o.addClassFocus) {
this.className = this.className.replace(o.addClassFocus, "");
this.parentNode.className = this.parentNode.className.replace("parent-"+o.addClassFocus, "");
}
}
}
}
}
function inputsSwap(el, el2) {
if(el) el.style.display = "none";
if(el2) el2.style.display = "inline";
}
}
// plugins init
function initPlugins(){
jQuery('ul.tabset').jqueryTabs({
addToParent:false,
holdHeight:false,
activeClass:'active',
tabLinks:'a.tab',
fadeSpeed:0
});
}
// jquery tabs plugin
jQuery.fn.jqueryTabs = function(_options){
// default options
var _options = jQuery.extend({
addToParent:false,
holdHeight:false,
activeClass:'active',
tabLinks:'a.tab',
fadeSpeed:300,
event:'click'
},_options);
return this.each(function(){
var _holder = jQuery(this);
var _fadeSpeed = _options.fadeSpeed;
var _activeClass = _options.activeClass;
var _addToParent = _options.addToParent;
var _holdHeight = _options.holdHeight;
var _tabLinks = jQuery(_options.tabLinks, _holder);
var _tabset = (_addToParent ? _tabLinks.parent() : _tabLinks);
var _event = _options.event;
var _animating = false;
// tabs init
_tabLinks.each(function(){
var _tmpLink = jQuery(this);
var _tmpTab = jQuery(_tmpLink.attr('href'));
var _classItem = (_addToParent ? _tmpLink.parent() : _tmpLink);
if(_tmpTab.length) {
if(_classItem.hasClass(_activeClass)) _tmpTab.show();
else _tmpTab.hide();
}
});
// tab switcher
function switchTab(_switcher) {
if(!_animating) {
var _link = jQuery(_switcher);
var _newItem = (_addToParent ? _link.parent() : _link);
var _newTab = jQuery(_link.attr('href'));
if(_newItem.hasClass(_activeClass)) return;
var _oldItem = jQuery(_addToParent ? _tabset : _tabLinks).filter('.'+_activeClass);
var _oldTab = jQuery(jQuery(_addToParent ? _oldItem.children('a') : _oldItem).attr('href'));
if(_newTab.length) {
_animating = true;
if(_oldItem.length) {
_newItem.addClass(_activeClass);
_oldItem.removeClass(_activeClass);
var _parent = _oldTab.parent();
if(_holdHeight) _parent.css({height:_parent.height()});
_oldTab.fadeOut(_fadeSpeed,function(){
_newTab.fadeIn(_fadeSpeed,function(){
_animating = false;
});
if(_holdHeight) _parent.css({height:'auto'});
});
} else {
_newItem.addClass(_activeClass);
_newTab.fadeIn(_fadeSpeed,function(){
_animating = false;
});
}
}
}
}
// control
_tabLinks.each(function(){
jQuery(this).bind(_event,function(){
switchTab(this);
return false;
});
});
});
}